<?php
  require_once 'DB.php';
  include_once("./libraries/db.inc.php");
  include_once("./libraries/util.inc.php");
  include_once("./libraries/authentication.inc.php");
  include_once("./queries/prov.inc.php");
  include_once("./libraries/recordset.inc.php");

  session_start();
  sessionAuthenticate("login.php");

  $dataIndex = "provDAGJobsAction";
  $displayPage = 1;

  // Process the GET variables
  foreach($_GET as $varName => $value) {
    if ($varName == "DAGManJobId") {
      $dagManJobId = $value;
      $_SESSION["{dataIndex}"]["dagManJobId"] = $dagManJobId;
    }
    if ($varName == "dP") {
      $displayPage = $value;
    }
  }

  $dagManJobId = $_SESSION["{dataIndex}"]["dagManJobId"];
  $title = "Jobs that are Part of a DAG";
  $message = "Jobs that are Part of DAG with DAGMan Job Id $dagManJobId";
  $username = $_SESSION["loginUsername"];


  // Connect to the database
  $connection = DB::connect($dsn, $options);
  if (DB::isError($connection)) {
    trigger_error($connection->getMessage(), E_USER_ERROR);
  }
  
  // Run the query
  $rs = dagJobsList($connection, $dagManJobId, $username, $displayPage);

  $connection->disconnect();

  $rs->printNavigablePage($title, $message, $displayPage, 
                          "./provDAGJobsAction.php");

  cdbFinishPage();
?>
